<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script type="text/javascript">
        var str = "abcdea";

        //给字符查索引(索引值为0,说明字符串以查询的参数为开头)
        console.log(str.indexOf("c"));
        console.log(str.lastIndexOf("c"));

        console.log(str.indexOf("a"));
        console.log(str.lastIndexOf("a"));
    </script>
</body>

</html>